import React, { Suspense } from "react";
import ErrorBoundary from "@/compnents/ErrorBoundary";
import { Spin } from "antd";
const withRetry = (callback) => (props) =>
  (
    <ErrorBoundary>
      {() => {
        // 封装懒加载外层传入callback
        const Component = React.lazy(callback);
        //  把外层每一个子组件都包裹一个ErrorBoundary 以及Suspense
        return (
          <Suspense
            fallback={
              <div>
                <Spin></Spin>请稍等。。。
              </div>
            }
          >
            <Component {...props} />
          </Suspense>
        );
      }}
    </ErrorBoundary>
  );
export default withRetry;
